package com.ruoyi.project.common.appchannel.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.common.appchannel.domain.AppChannel;
import com.ruoyi.project.common.appchannel.mapper.AppChannelMapper;
import com.ruoyi.project.common.appchannel.service.IAppChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 应用渠道Service业务层处理
 *
 * @author shixiangwen
 * @date 2022-03-21
 */
@Service
@DataSource(DataSourceType.KKAD)
public class AppChannelServiceImpl implements IAppChannelService {

    @Autowired
    private AppChannelMapper appChannelMapper;

    /**
     * 查询应用渠道
     *
     * @param id 应用渠道ID
     * @return 应用渠道
     */
    @Override
    public AppChannel selectAppChannelById(Long id) {
        return appChannelMapper.selectAppChannelById(id);
    }

    /**
     * 查询应用渠道列表
     *
     * @param appChannel 应用渠道
     * @return 应用渠道
     */
    @Override
    public List<AppChannel> selectAppChannelList(AppChannel appChannel) {
        return appChannelMapper.selectAppChannelList(appChannel);
    }

    /**
     * 新增应用渠道
     *
     * @param appChannel 应用渠道
     * @return 结果
     */
    @Override
    public int insertAppChannel(AppChannel appChannel) {
        appChannel.setCreatedTime(DateUtils.getNowDate());
        return appChannelMapper.insertAppChannel(appChannel);
    }

    /**
     * 修改应用渠道
     *
     * @param appChannel 应用渠道
     * @return 结果
     */
    @Override
    public int updateAppChannel(AppChannel appChannel) {
        return appChannelMapper.updateAppChannel(appChannel);
    }

    /**
     * 删除应用渠道对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteAppChannelByIds(String ids) {
        return appChannelMapper.deleteAppChannelByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除应用渠道信息
     *
     * @param id 应用渠道ID
     * @return 结果
     */
    @Override
    public int deleteAppChannelById(Long id) {
        return appChannelMapper.deleteAppChannelById(id);
    }
}
